use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
use yata::core::PeriodType;
use yata::core::ValueType;

use super::IndicatorActionWrap;

///
/// Struct to hold the results of Struct yata::indicators::TrendStrengthIndex
///
///
#[derive(Serialize, Deserialize, Default, Debug, TS, Clone)]
#[ts(export)]
pub struct TDSI {
    /// 2 signals
    /// When main value crosses upper zone downwards, gives full negative #1 signal.
    /// When main value crosses lower zone upwards, gives full positive #1 signal.
    pub signal0: Option<IndicatorActionWrap>,

    /// When main value is below lower zone and changes direction upwards, gives full positive #2 signal
    /// When main value is above upper zone and changes direction downwards, gives full negative #2 signal
    pub signal1: Option<IndicatorActionWrap>,

    /// 1 value
    /// Main value
    /// Range in [-1.0; 1.0]
    pub main: ValueType,
}

/// Configuration
#[derive(Serialize, Deserialize, Debug, TS, Clone, Copy)]
#[ts(export)]
pub struct TDSIConfig {
    /// Main period length. Default is 14.
    ///
    /// Range in [2; PeriodType::MAX).
    pub period: PeriodType,

    ///Zone value determines when signal #2 appears. Default is 0.75.
    ///
    ///Range in [0.0; 1.0).
    pub zone: ValueType,

    /// Reverse period
    ///
    /// Range in [1; PeriodType::MAX/2].
    pub reverse_offset: PeriodType,
    // source: Source
    // Source type of values. Default is Close.
}

impl Default for TDSIConfig {
    fn default() -> Self {
        Self {
            period: 14,
            zone: 0.75,
            reverse_offset: 1,
            // source: Source::Close,
        }
    }
}
